<template>
	<view class="main">
		<zmm-watermark :watermark="watermark"></zmm-watermark>
		<h3>{{data.name}}</h3>
		<p class="time">{{data.updatetime}}</p>
		<p>{{data.content}}</p>
	</view>
</template>

<script>
	import {
		Noticesread
	} from '@/api/inner.js'
	export default {
		data() {
			return {
				id: '',
				data: {},
				watermark: '',
			}
		},
		onLoad(e) {
			this.id = e.id
			this.getDetail()
			this.watermark = uni.getStorageSync('watermark')
		},
		methods: {
			async getDetail() {
				let res = await Noticesread({
					id: this.id
				})
				console.log(res)
				res.data.updatetime = this.timestampToDate2(res.data.updatetime)
				console.log(this.timestampToDate2(new Date()))
				this.timestampToDate2(res.data.updatetime)
				this.data = res.data
			},
			timestampToDate2(timestamp) {
				const date = new Date(timestamp);
				const year = date.getFullYear();
				const month = String(date.getMonth() + 1).padStart(2, '0');
				const day = String(date.getDate()).padStart(2, '0');
				return `${year}-${month}-${day}`;
			}
		}
	}
</script>

<style lang="scss" scoped>
	.main {
		min-height: calc(100vh - 44px);
		background-color: #F2F2F2;
		padding: 10px 15px 10px;
		background-color: #fff;

		h3 {
			font-size: 16px;
			margin-bottom: 5px;
		}

		.time {
			font-size: 14px;
			color: #666666;
			margin-bottom: 15px;
		}
	}
</style>